package ryarithsGame;

import com.jme.math.Vector2f;
import com.jme.math.Vector3f;
import com.jme.scene.Node;

public class Level3 extends Node 
{

	private PuzzleNode[] puzzle;
	private Goal goal;
	private static final long serialVersionUID = 1L;

	public Level3()
	{
		super("Level3");
		loadPuzzle();
	}
	
	private void loadPuzzle()
	{
		goal = new Goal("goal", new Vector3f(500,15,100));
		puzzle = new PuzzleNode[3];
		puzzle[0] = new PuzzleNode("switch0", 1, new Vector3f(500,10,110),new Vector3f(100,10,100));
		puzzle[1] = new PuzzleNode("switch1", 0, new Vector3f(110,10,500),new Vector3f(500,10,100));
		puzzle[2] = new PuzzleNode("switch2", 1, new Vector3f(100,10,500),new Vector3f(105,10,500));
		this.attachChild(goal);
		this.attachChild(puzzle[0]);
		this.attachChild(puzzle[1]);
		this.attachChild(puzzle[2]);
	}
	
	public void updateLevel(float tpf)
	{
		for(int i = 0; i < puzzle.length; i++)
		{
			puzzle[i].updatePuzzleNode(tpf);
		}
		goal.updateGoalNode();	
	}
	
	public void checkSwitchCollisions(Vector2f camPos)
	{
		goal.checkSwitchCollisions(camPos);
	}
	
	public boolean getGoalSwitch()
	{
		return goal.getIsSwitched();
	}
	
	public PuzzleNode getPuzzleNode(int i)
	{
		return puzzle[i];
	}
	
	public int puzzleSize()
	{
		return puzzle.length;
	}
	
}
